package com.elitetyc.customview.transform;

import android.support.annotation.NonNull;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.widget.PopupWindow;

/**
 * Created by elitetyc on 2019/4/4.
 * Describe:
 */
public class GalleryTransformer implements ViewPager.PageTransformer {
    private static  final float MIN_SACLE = 0.85f;
    private static  final float MIN_ALPHA = 0.5f;
    private static  final float MIN_ROTATE = 30;
    @Override
    public void transformPage(@NonNull View view, float v) {
        float scaleFactor = Math.min(MIN_SACLE,1-Math.abs(v));
        float rotate = 20*Math.abs(v);
        if (v<-1){

        }else if (v<0){
            view.setScaleX(scaleFactor);
            view.setScaleY(scaleFactor);
            view.setRotationY(rotate);
        }else if (v>=0&&v<1){
            view.setScaleX(scaleFactor);
            view.setScaleY(scaleFactor);
            view.setRotationY(-rotate);
        }else if (v>=1){
            view.setScaleX(scaleFactor);
            view.setScaleY(scaleFactor);
            view.setRotationY(-rotate);
        }


    }
}
